home *** CD-ROM | disk | FTP | other *** search
- /*
- File: StylePrimitives.c
-
- Contains: QuickDraw GX to PostScript conversion code.
- File contains routines for translating various
- style attributes into PostScript
-
- Version: Technology: Quickdraw GX 1.1.x
-
- Copyright: © 1991-1997 by Apple Computer, Inc., all rights reserved.
- */
-
- #include "GXToPSBuildConfig.h"
- #include <GXGraphics.h>
- #include "GXGraphicsPriv.h"
- #include <GXEnvironment.h>
- #include "GXToPostScript.h"
- #include "IOUtilities.h"
- #include "RDUtil.h"
- #include "PublicPostScriptIE.h"
- #include "private.h"
- #include "PSIEResources.h"
- #include "GXErrors.h"
-
- #ifdef resumeLabel
- #undef resumeLabel
- #endif
- #define resumeLabel(exception)
-
-
-
- //<FF>
- /*******************************
-
- GetPSDashPhase:
-
- Converts the phase from the dash record
- into the appropriate value for PostScript.
-
- gx graphics phases are fractions of the advance into the path,
- PostScript phases are distances into the dash
-
- *********************************/
- Fixed GetPSDashPhase(gxDashRecord *theDash);
- Fixed GetPSDashPhase(gxDashRecord *theDash)
- {
- register Fixed thePhase;
-
- thePhase = FractMultiply(theDash->advance, theDash->phase);
-
- return(-thePhase); // negate because PS is into dash and gx graphics is into path.
-
- }//GetPSDashPhase
-
- //<FF>
- #define FRACROOT2less1 444758426
- #define ROOT2less1 FractToFixed(FRACROOT2less1)
- #define fixOneHalf ((Fixed) 0x00008000) /* fixed 0.5 */
- /************************************
- TestCapsRound:
-
- start, end: the start and end cap shapes
-
- To pass the test:
- each path must be a path such that
- contours = 1;
- #points in each contour = 6;
- first and last point of each is on curve, rest are off:
-
-
- For start
-
- x1 = 0, y1 =-0.5
- x2 = -(sqrt(2) - 1)/2, y2 = -0.5
- x3 = -0.5, y3 = -(sqrt(2) - 1)/2
- x4 = -0.5, y4 = (sqrt(2) - 1)/2
- x5 = -(sqrt(2) - 1)/2, y5 = 0.5
- x6 = 0, y6 = 0.5
-
-
- For End
- mirror version of above (x's are negated)
-
- *************************************/
- Boolean TestCapsRound(gxShape start, gxShape end);
- Boolean TestCapsRound(gxShape start, gxShape end)
- {
- OSErr status;
- Ptr inStartPath;
- Ptr inEndPath;
- gxPoint* pPoint;
- long cBitsStart, cBitsEnd;
- Boolean isRound = false;
- long size;
-
-
- /** Make sure the paths are in a known direction to minimize checks **/
-
- if (GXGetShapeDirection(start, 1) == gxClockwiseDirection) // We want start-cap counter-clockwise.
- GXReverseShape(start, 1);
-
- if (GXGetShapeDirection(end, 1) == gxCounterclockwiseDirection) // We want end-cap clockwise.
- GXReverseShape(end, 1);
-
-
-
- GXSetShapeAttributes(start, gxDirectShape);
- GXSetShapeAttributes(end, gxDirectShape);
-
- GXLockShape(start);
- GXLockShape(end);
- inStartPath = (Ptr)GXGetShapeStructure(start, &size);
- inEndPath = (Ptr)GXGetShapeStructure(end, &size);
-
- status = GXGetGraphicsError(nil);
- nrequire(status, failed_GetShape);
-
- if ( (*(long*)inStartPath == 1) && (*(long*)inEndPath == 1) ) {
-
- /** Skip past number of contours, now at #points in contour **/
- inStartPath += sizeof(long);
- inEndPath += sizeof(long);
-
- if ( (*(long*)inStartPath == 6) && (*(long*)inEndPath == 6)) {
-
- inStartPath += sizeof(long); // Skip past #points in contour
- inEndPath += sizeof(long);
-
- cBitsStart = *(long*)inStartPath; // Get start-cap control bits.
- cBitsEnd = *(long*)inEndPath; // Get end-cap control bits.
-
- if ( (cBitsStart == 0x78000000) && (cBitsEnd == 0x78000000)) {
-
- inStartPath += sizeof(long); // Skip past control bits.
- inEndPath += sizeof(long);
-
- pPoint = (gxPoint*)inStartPath;
- if ((pPoint->x != 0) || (pPoint->y != -fixOneHalf))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != -(ROOT2less1 >> 1)) || (pPoint->y != -fixOneHalf))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != -fixOneHalf) || (pPoint->y != -(ROOT2less1 >> 1)))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != -fixOneHalf) || (pPoint->y != (ROOT2less1 >> 1)))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != -(ROOT2less1 >> 1)) || (pPoint->y != fixOneHalf))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != 0) || (pPoint->y != fixOneHalf))
- goto IsNotRound;
-
- /** Check end cap **/
-
- pPoint = (gxPoint*)inEndPath;
- if ((pPoint->x != 0) || (pPoint->y != -fixOneHalf))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != (ROOT2less1 >> 1)) || (pPoint->y != -fixOneHalf))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != fixOneHalf) || (pPoint->y != -(ROOT2less1 >> 1)))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != fixOneHalf) || (pPoint->y != (ROOT2less1 >> 1)))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != (ROOT2less1 >> 1)) || (pPoint->y != fixOneHalf))
- goto IsNotRound;
-
- ++pPoint;
- if ((pPoint->x != 0) || (pPoint->y != fixOneHalf))
- goto IsNotRound;
-
-
-
- isRound = true;
-
- }//end if
-
- }//end if
-
- }//end if
-
-
- IsNotRound:
- failed_GetShape:
-
- GXUnlockShape(start);
- GXUnlockShape(end);
-
- return(isRound);
-
- }//TestCapsRound;
-
- //<FF>
- /****************************
- GetPSLineCap:
-
- Determine if caps are PostScriptable
- either by geometric analysis or looking
- at line cap synonym tags.
-
- Routine checks for synonym. Routine
- also tags the style with the synonym
- when it detects a PostScriptable end cap.
- This is because the routine will actually be
- called twice per style. Once in VallidateFillShape
- and once when translating the Style to PostScript.
-
- Returns -1 if cap isn't postscriptable.
-
- *****************************/
- OSErr _GetPSLineCap(gxStyle theStyle, long *psCap)
- {
- gxCapRecord theCaps;
- gxRectangle startRect, endRect;
- gxTag aTag;
- long tagSize;
-
- *psCap = -1;
-
- GXGetStyleCap(theStyle, &theCaps);
-
- /* Use the synonym only if the style really has caps */
-
- if (GXGetStyleTags(theStyle, gxLineCapSynonymTag, 1, 1, &aTag) && ( (theCaps.startCap != nil) || (theCaps.endCap != nil) ) ) {
-
- /* Get the line cap synonym value */
-
- GXLockTag(aTag);
- *psCap = *(long*)((char*)GXGetTagStructure(aTag, &tagSize) - tagStructureBugOffset);
- GXUnlockTag(aTag);
-
- } else {
-
- /* Try to determine what kind of line cap it is */
-
- if ( (theCaps.startCap == nil) && (theCaps.endCap == nil) ) {
-
- *psCap = gxButtCap;
-
- } else if ( (theCaps.startCap == nil) || (theCaps.endCap == nil) ) { // one or other nil means non-PSable.
-
- *psCap = -1;
-
- } else if (theCaps.attributes & (gxLevelStartCap | gxLevelEndCap)) {
-
- *psCap = -1; // level-cap is not PostScriptable.
-
- } else {
-
- /** The bounding rectangles must be -0.5 -> 0.5 by 0 -> 0.5 to be a PS cap. **/
-
- GXGetShapeBounds(theCaps.startCap, 1, &startRect);
- GXGetShapeBounds(theCaps.endCap, 1, &endRect);
-
- if ( (startRect.top == -fixOneHalf) && (startRect.bottom == fixOneHalf) &&
- (startRect.left == -fixOneHalf) && (startRect.right == 0) &&
- (endRect.top == -fixOneHalf) && (endRect.bottom == fixOneHalf) &&
- (endRect.left == 0) && (endRect.right == fixOneHalf) ) {
-
- if ((GXGetShapeType(theCaps.startCap) == gxRectangleType) && (GXGetShapeType(theCaps.endCap) == gxRectangleType)) {
-
- *psCap = gxSquareCap;
-
- } else if ((GXGetShapeType(theCaps.startCap) == gxPathType) && (GXGetShapeType(theCaps.endCap) == gxPathType)) {
-
- if (TestCapsRound(theCaps.startCap, theCaps.endCap))
- *psCap = gxRoundCap;
-
- }//end if
-
-
- } else {
-
- *psCap = -1;
-
- }//end if
-
-
- }//end if
-
-
- /* Tag the style so next time we look at it we're faster */
-
- aTag = GXNewTag(gxLineCapSynonymTag, sizeof(gxLineCapSynonym), psCap);
- GXSetStyleTags(theStyle, gxLineCapSynonymTag, 0, 0, 1, &aTag);
- GXDisposeTag(aTag);
-
- }//end if
-
- if (theCaps.startCap != nil)
- GXDisposeShape(theCaps.startCap);
-
- if (theCaps.endCap != nil)
- GXDisposeShape(theCaps.endCap);
-
- return(noErr);
-
- }//GetPSLineCap
-
-
-
-
- //<FF>
- /*****************************************
- MakeDashDict:
-
- Routine takes a dash record and outputs the
- PostScript code leaving a valid dashing dictionary
- on the operand stack.
-
- ******************************************/
- OSErr _MakeDashDict(TIEGlobalsHdl hIEGlobals, gxDashRecord* pDash, gxStyleAttribute theAttributes)
- {
- #pragma unused (theAttributes)
- OSErr status;
- TRDParams* pRDParams;
- Boolean dolevelDash;
- Boolean doAutoAdvance;
- Boolean doBreakDash;
-
- dolevelDash = (pDash->attributes & gxLevelDash)? true : false;
- doAutoAdvance = (pDash->attributes & gxAutoAdvanceDash)? true : false;
- doBreakDash = (pDash->attributes & gxBreakDash)? true : false;
-
- /** First leave the shape dictionary on the stack. **/
-
- nrequire(status = MakeShapeDict(hIEGlobals, pDash->dash, eNoGeomOptions), failed_Geometry);
-
- /** Make the dash dictionary **/
-
- pRDParams = (*hIEGlobals)->pRDParams;
- pRDParams->resIndex = kMakeDashDict;
- status = RDResPrintf(pRDParams, (long)doAutoAdvance, (long)dolevelDash, (long)doBreakDash,
- pDash->advance, GetPSDashPhase(pDash), pDash->scale);
- nrequire(status, failed_Output);
-
- failed_Output:
- failed_Geometry:
- return(status);
-
- }//MakeDashDict
-
- //<FF>
- /******************************
- MakePatternPostScriptable:
-
- Checks to see if a shape's pattern can be
- rendered by our PostScript procedures (or level-II)
-
- It can't if the shape is evenOddFilled and the lattice
- causes overlap of the pattern shapes.
-
- We fix this by generating a new pattern shape that contains
- overlapping copies of the original pattern shape, clipped to
- the parallelogram defined by U and V.
-
- *******************************/
- void MakePatternPostScriptable(gxPatternRecord *thePattern, gxStyleAttribute theAttributes)
- {
- #pragma unused (theAttributes)
-
- gxShapeType theType;
- gxRectangle theBounds;
- gxShape shapeAtU, shapeAtV, shapeAtUplusV, cellShape, newPattern;
- gxMapping mapToXY, mapToUV;
- gxPoint patternLocInUV, patternLocInXY;
- gxPoint dimensions;
- short width, height;
- Fixed dx, dy;
-
- theType = GXGetShapeType(thePattern->pattern);
-
- if ( (theType == gxTextType) || (theType == gxLayoutType) || (theType == gxGlyphType) ||
- (theType == gxBitmapType) )
- return;
-
-
- if (GXGetShapeFill(thePattern->pattern) != gxEvenOddFill)
- return;
-
- /** If we got here then see if pattern shapes will overlap in lattice cells **/
-
- shapeAtU = GXCopyToShape(nil, thePattern->pattern);
- GXMoveShape(shapeAtU, thePattern->u.x, thePattern->u.y);
-
- shapeAtV = GXCopyToShape(nil, thePattern->pattern);
- GXMoveShape(shapeAtV, thePattern->v.x, thePattern->v.y);
-
- shapeAtUplusV = GXCopyToShape(nil, thePattern->pattern);
- GXMoveShape(shapeAtUplusV, thePattern->v.x + thePattern->u.x, thePattern->v.y + thePattern->u.y);
-
- if ( GXTouchesShape(thePattern->pattern, shapeAtU) ||
- GXTouchesShape(thePattern->pattern, shapeAtV) ||
- GXTouchesShape(thePattern->pattern, shapeAtUplusV) ||
- GXTouchesShape(shapeAtU, shapeAtV) ) {
-
- GXDisposeShape(shapeAtU);
- GXDisposeShape(shapeAtV);
- GXDisposeShape(shapeAtUplusV);
-
- /** Translate the pattern shape so its bounds are within the first pattern lattice **/
-
- GXGetShapeBounds(thePattern->pattern, 0, &theBounds);
-
- /** Make a mapping to map into pattern space **/
-
- mapToXY.map[0][0] = thePattern->u.x;
- mapToXY.map[0][1] = thePattern->u.y;
- mapToXY.map[0][2] = 0;
-
- mapToXY.map[1][0] = thePattern->v.x;
- mapToXY.map[1][1] = thePattern->v.y;
- mapToXY.map[1][2] = 0;
-
- mapToXY.map[2][0] = 0;
- mapToXY.map[2][1] = 0;
- mapToXY.map[2][2] = fract1;
-
- InvertMapping(&mapToUV, &mapToXY);
-
- patternLocInUV.x = theBounds.left;
- patternLocInUV.y = theBounds.top;
-
- //dprintf(trace, "Starting Location: %F %F", theBounds.left, theBounds.top);
-
- MapPoints(&mapToUV, 1, &patternLocInUV);
-
- /******
- Find location of pattern shape in 0,0 pattern cell,
- fractional part of its UV coordinates.
- ******/
- //dprintf(trace, "Location in UV: %F %F", patternLocInUV.x, patternLocInUV.y);
-
- patternLocInUV.x &= 0x0000FFFF;
-
- patternLocInUV.y &= 0x0000FFFF;
-
- //dprintf(trace, "Move Location in UV to: %F %F", patternLocInUV.x, patternLocInUV.y);
-
- patternLocInXY = patternLocInUV; // map this location back to XY space
- MapPoints(&mapToXY, 1, &patternLocInXY);
-
- //dprintf(trace, "Moving shape by: %F %F", patternLocInXY.x, patternLocInXY.y);
-
- GXMoveShape(thePattern->pattern, patternLocInXY.x - theBounds.left,
- patternLocInXY.y - theBounds.top);
-
- /** Now the pattern shape is translated as it would be when drawn in the first lattice point **/
-
- /** Find the pattern shape's dimensions UV space **/
-
- shapeAtU = GXCopyToShape(nil, thePattern->pattern);
- GXMapShape(shapeAtU, &mapToUV);
- GXGetShapeBounds(shapeAtU, 0, &theBounds);
- GXDisposeShape(shapeAtU);
-
- dimensions.x = theBounds.right - theBounds.left;
- dimensions.y = theBounds.bottom - theBounds.top;
- width = 1 + (long)(dimensions.x >> 16) / 2;
- height = 1 + (long)(dimensions.y >> 16) / 2;
-
- //dprintf(trace, "Width is: %d Height is: %d", width, height);
-
- /***
- Make a new pattern shape that is the union of the pattern shape drawn at the
- necessary lattice points.
- ****/
- theBounds.left = 0;
- theBounds.top = 0;
- theBounds.bottom = ff(1);
- theBounds.right = ff(1);
- cellShape = GXNewRectangle(&theBounds);
- GXMapShape(cellShape, &mapToXY);
-
- newPattern = GXNewShape(gxEmptyType); // Start with a new shape.
-
- GXGetShapeBounds(thePattern->pattern, 0, &theBounds); // get them again, we wrote over them.
-
- for (dx = -ff(width); dx <= ff(width); dx += ff(1) ) {
-
- for (dy = -ff(height); dy <= ff(height); dy += ff(1) ) {
-
- patternLocInXY.x = dx;
- patternLocInXY.y = dy;
- MapPoints(&mapToXY, 1, &patternLocInXY);
-
- shapeAtV = GXCopyToShape(nil, thePattern->pattern);
- GXMoveShape(shapeAtV, patternLocInXY.x, patternLocInXY.y);
-
- if (GXTouchesShape(cellShape, shapeAtV))
- GXSetShapeParts(newPattern, 0, 0, shapeAtV, gxBreakLeftEdit);
-
- GXDisposeShape(shapeAtV);
-
- }//end for
-
- }//end for
-
- /** Now clip the new shape to the lattice cell **/
-
-
- GXIntersectShape(newPattern, cellShape);
-
- GXDisposeShape(cellShape);
-
- GXDisposeShape(thePattern->pattern);
- thePattern->pattern = newPattern;
-
- } else { //end if
-
- GXDisposeShape(shapeAtU);
- GXDisposeShape(shapeAtV);
-
- }//end if
-
- }//MakePatternPostScriptable
-
-
-
- //<FF>
- /*****************************************
- MakePatternDict:
-
- Routine takes a Pattern record and outputs the
- PostScript code leaving a valid Patterning dictionary
- on the operand stack.
-
- ******************************************/
- OSErr _MakePatternDict(TIEGlobalsHdl hIEGlobals, gxPatternRecord* pPattern, gxStyleAttribute theAttributes)
- {
- OSErr status;
- TRDParams* pRDParams;
- gxPoint phase;
- Boolean doMapPort, doPortAllign;
-
- MakePatternPostScriptable(pPattern, theAttributes);
-
- phase.x = 0;
- phase.y = 0;
-
- /** First leave the shape dictionary on the stack. **/
-
- status = MakeShapeDict(hIEGlobals, pPattern->pattern, eNoGeomOptions);
- nrequire(status, failed_Geometry);
-
- /** Make the pattern dictionary **/
-
- // map port if attribute set, but only for bitmap patterns, attribute ignored otherwise.
- doMapPort = ((pPattern->attributes & gxPortMapPattern) && (GXGetShapeType(pPattern->pattern) == gxBitmapType)) ? true : false;
- doPortAllign = (pPattern->attributes & gxPortAlignPattern)? true : false;
-
- pRDParams = (*hIEGlobals)->pRDParams;
- pRDParams->resIndex = kMakePatDict;
- status = RDResPrintf(pRDParams, &(pPattern->u), &(pPattern->v), &phase, (long)doMapPort, (long)doPortAllign );
- nrequire(status, failed_Output);
-
- failed_Output:
- failed_Geometry:
- return(status);
-
- }//MakePatternDict
-
-
-
- //<FF>
- /**********************************************
-
- Routine: DoDashSynonym:
-
- Routine outputs the data in a dash synonym for the SetDash operator.
- operator. Data output in the form same as PostScript "setdash" operator.
-
- pRDParams: Pointer to RDUtilities parameter block.
- pDashSyn: Pointer to a dash synonym record from the style.
- pDash: Pointer to the dash record from the style.
-
- ***********************************************/
- OSErr DoDashSynonym(TIEGlobalsHdl hGlobals, TRDParams* pRDParams, gxDashSynonym* pDashSyn, gxDashRecord *pDash);
- OSErr DoDashSynonym(TIEGlobalsHdl hGlobals, TRDParams* pRDParams, gxDashSynonym* pDashSyn, gxDashRecord *pDash)
- {
- OSErr status;
- Fixed* pVal;
- register short i;
-
- /* Output the array of values onto the operand stack */
-
- nrequire(status = DoBeginArray(hGlobals), failed_Output);
-
- pRDParams->resIndex = kDoFixed;
- pVal = pDashSyn->dashLength; // value pointer at beginning of array.
- for (i = pDashSyn->size - 1; i >= 0; --i) {
-
- nrequire(status = RDResPrintf(pRDParams, *pVal++), failed_Output);
-
- }//end for
-
- nrequire(status = DoEndArray(hGlobals), failed_Output);
-
- /** Output the phase of the dash **/
-
- nrequire(status = RDResPrintf(pRDParams, GetPSDashPhase(pDash)), failed_Output);
-
-
- failed_Output:
- return(status);
-
- }//DoDashSynonym
-
-
-
- //<FF>
- /**********************************************
-
- Routine: FrameStylePrimitive:
-
- Routines sets all of the style attributes in the
- PostScript graphics state associated with the frame
- shape.
-
- ***********************************************/
- OSErr FrameStylePrimitive(TIEGlobalsHdl hIEGlobals, gxStyle theStyle)
- {
- OSErr status = noErr;
- TRDParams* pRDParams;
- TIEGlobalsPtr pGlobals;
- gxJoinRecord theJoin;
- gxDashRecord theDash;
- gxDashSynonym *pDashSyn;
- gxStyleAttribute theAttributes;
- long psVal; // enumerated postscript value for line cap and join.
- Fixed aValue;
- gxTag aTag;
- long tagSize;
-
-
- pGlobals = *hIEGlobals;
-
- pRDParams = pGlobals->pRDParams;
-
- theAttributes = GXGetStyleAttributes(theStyle);
-
- /** Do the frame attributes **/
- psVal = GetPSFrameValue(theAttributes);
- if ((psVal!= pGlobals->psFrameValue) || (pGlobals->ieStateFlags & eStyleOutOfDate)) {
-
- pGlobals->psFrameValue = psVal;
-
- pRDParams->resIndex = kSetFrame;
- nrequire(status = RDResPrintf(pRDParams, psVal), failed_Output);
-
- /** Refresh pointers, handle may have moved. **/
- pGlobals = *hIEGlobals;
-
- }//end if
-
-
-
- /** Do the line Cap **/
-
- status = _GetPSLineCap(theStyle, &psVal);
- nrequire(status, failed_Skia);
-
- if ((psVal != -1) && ( (pGlobals->lineCap != psVal ) || (pGlobals->ieStateFlags & eStyleOutOfDate)) ) {
-
- pGlobals->lineCap = psVal;
- pRDParams->resIndex = kSetLineCap;
- nrequire(status = RDResPrintf(pRDParams, psVal), failed_Output);
-
- /** Refresh pointers, handle may have moved. **/
- pGlobals = *hIEGlobals;
-
- }//end if
-
-
- /** Do the line width **/
-
- aValue = GXGetStylePen(theStyle);
- if ((pGlobals->lineWidth != aValue) || (pGlobals->ieStateFlags & eStyleOutOfDate)) {
-
- pGlobals->lineWidth = aValue;
- pRDParams->resIndex = kSetLineWidth;
- nrequire(status = RDResPrintf(pRDParams, aValue), failed_Output);
-
- /** Refresh pointers, handle may have moved. **/
- pGlobals = *hIEGlobals;
-
- }//end if
-
- /** Do the line join **/
-
- GXGetStyleJoin(theStyle, &theJoin);
- psVal = GetPSLineJoin(&theJoin);
- status = GXGetGraphicsError(nil);
- nrequire(status, failed_Skia);
-
- if ((psVal != -1) && ( (pGlobals->lineJoin != psVal) || (pGlobals->ieStateFlags & eStyleOutOfDate)) ) {
-
- pGlobals->lineJoin = psVal;
- pRDParams->resIndex = kSetLineJoin;
- nrequire(status = RDResPrintf(pRDParams, psVal), failed_Output);
-
- /** Refresh pointers, handle may have moved. **/
- pGlobals = *hIEGlobals;
-
- }//end if
-
-
- if (theJoin.join != nil)
- GXDisposeShape(theJoin.join);
-
-
- /** Do the miter limit **/
-
- aValue = SkiaMiterToPS(theJoin.miter, pGlobals->lineWidth);
-
- if ((aValue != pGlobals->miterLimit) || (pGlobals->ieStateFlags & eStyleOutOfDate)) {
-
- pGlobals->miterLimit = aValue;
- pRDParams->resIndex = kSetMiterLim;
- nrequire(status = RDResPrintf(pRDParams, aValue), failed_Output);
-
- pGlobals = *hIEGlobals;
-
- }//end if
-
-
- /******
- Do the dash:
- If there is a synonym, put its data on the stack. If there is a dash shape
- make a dash dictionary, put it on stack - Else put null on stack
- ******/
-
- GXGetStyleDash(theStyle, &theDash); // Get the real dash record
-
- /* Get dashing synonym if available */
-
- if (GXGetStyleTags(theStyle, gxDashSynonymTag, 1, 1, &aTag) && (theDash.dash != nil)) {
-
- pGlobals->ieStateFlags |= eHasDash;
- pGlobals->ieStateFlags &= ~eSimpleStyle;
-
- GXLockTag(aTag);
- pDashSyn = (gxDashSynonym*)((char*)GXGetTagStructure(aTag, &tagSize) - tagStructureBugOffset);
-
- nrequire_action(status = DoDashSynonym(hIEGlobals, pRDParams, pDashSyn, &theDash), failed_Dash, GXUnlockTag(aTag););
-
- /* Do the SetDash operator */
- pRDParams->resIndex = kSetDash;
- status = RDResPrintf(pRDParams);
- GXUnlockTag(aTag);
-
- if (theDash.dash)
- GXDisposeShape(theDash.dash);
-
- nrequire(status, failed_Output);
-
- } else if (theDash.dash != nil) {
-
- pGlobals->ieStateFlags |= eHasDash;
- pGlobals->ieStateFlags &= ~eSimpleStyle;
-
- nrequire(status = _MakeDashDict(hIEGlobals, &theDash, theAttributes), failed_Dash);
-
- /* Do the SetDash operator */
- pRDParams->resIndex = kSetDash;
- nrequire(status = RDResPrintf(pRDParams), failed_Output);
-
- GXDisposeShape(theDash.dash);
-
- } else {
-
- // if previous shape had dash and current one doesn't , output null for SetDash.
-
- if ((pGlobals->ieStateFlags & eHasDash) || (pGlobals->ieStateFlags & eStyleOutOfDate)) {
-
- pGlobals->ieStateFlags &= ~eHasDash;
- nrequire(status = DoNull(pRDParams), failed_Output);
-
- /* Do the SetDash operator */
- pRDParams->resIndex = kSetDash;
- nrequire(status = RDResPrintf(pRDParams), failed_Output);
-
- }//end if
-
-
- }//end if
-
-
- /** If you put any more code after here, make sure to refresh pGlobals **/
-
- failed_Dash:
- failed_Skia:
- failed_Output:
-
-
- return(status);
-
-
- }//FrameStylePrimitive
-
-
- //<FF>
- /**********************************************
-
- Routine: MiscStylePrimitive:
-
- Routines sets all the attributes of the style
- in the PostScript graphics state that affect
- all shapes, framed or filled.
-
-
- ***********************************************/
- OSErr MiscStylePrimitive(TIEGlobalsHdl hIEGlobals, gxStyle theStyle)
- {
- OSErr status = noErr;
- TIEGlobalsPtr pGlobals;
- TRDParams *pRDParams;
- gxStyleAttribute theAttributes;
- Boolean rIsOut;
- gxPatternRecord thePattern;
- Boolean changedPattern = false;
-
-
- pGlobals = *hIEGlobals;
- pRDParams = pGlobals->pRDParams;
-
- /** Output the curve error **/
-
- #ifdef useCurveError
- aValue = GXGetStyleCurveError(theStyle);
- if ((aValue != pGlobals->curveFlat) || pGlobals->initializeGstate) {
-
- pGlobals->curveFlat = aValue;
-
- pRDParams->resIndex = kSetFlat;
- status = RDResPrintf(pRDParams, aValue);
- nrequire(status, failed_Output);
-
- /** Refresh pointers, handle may have moved. **/
- pGlobals = *hIEGlobals;
-
- }//end if
- #endif
-
- /** Output other style attributes **/
-
- theAttributes = GXGetStyleAttributes(theStyle);
- rIsOut = (theAttributes & gxAutoInsetStyle);
- if ((rIsOut != pGlobals->currRightIsOut) || (pGlobals->ieStateFlags & eStyleOutOfDate)) {
-
- pGlobals->currRightIsOut = rIsOut;
-
- pRDParams->resIndex = kSetRightIsOut;
- status = RDResPrintf(pRDParams, rIsOut);
- nrequire(status, failed_Output);
-
- /** Refresh pointers, handle may have moved. **/
- pGlobals = *hIEGlobals;
-
- }//end if
-
- /******* Output the pattern if there is one ************/
-
- GXGetStylePattern(theStyle, &thePattern);
- status = GXGetGraphicsError(nil);
- nrequire(status, failed_Skia);
-
-
- /** If there is a pattern shape, make a pattern dictionary, put it on stack - Else put null on stack **/
- if (thePattern.pattern != nil) {
-
- /** Mark persistent state as having pattern **/
- pGlobals->ieStateFlags |= eHasPattern;
-
- /** Patterns not simple, need to output QD2Fill **/
- pGlobals->ieStateFlags &= ~eSimpleStyle;
-
- status = _MakePatternDict(hIEGlobals, &thePattern, theAttributes);
- nrequire(status, failed_Pattern);
-
- changedPattern = true;
-
- GXDisposeShape(thePattern.pattern);
-
- } else {
-
- // if previous shape had pattern and current one doesn't , output null SetPat.
-
- if ((pGlobals->ieStateFlags & eHasPattern) || (pGlobals->ieStateFlags & eStyleOutOfDate)) {
-
- /** Mark persistent state as not having pattern **/
- pGlobals->ieStateFlags &= ~eHasPattern;
-
- nrequire(status = DoNull(pRDParams), failed_Output);
-
- changedPattern = true;
-
- }//end if
-
- }//end if
-
- /** If we downloaded a new pattern or are changing it to null, issue the SetPat operator **/
-
- if (changedPattern) {
-
- pRDParams->resIndex = kSetPattern;
- nrequire(status = RDResPrintf(pRDParams), failed_Output);
-
- }//end if
-
- failed_Pattern:
- failed_Skia:
- failed_Output:
- return(status);
-
- }//MiscStylePrimitive
-
-
-
-